'use strict';
var _ = require('lodash');
var Injector = require('injector');
var winston = require('winston');
var Logger = winston.Logger;
var RotateFile = require('winston-daily-rotate-file');

module.exports = Injector.define([
    'config/logger',
], createModule);

function createModule(loggerConfig) {
    var transports = {
        console:winston.transports.Console,
        file:winston.transports.File,
        memory:winston.transports.Memory,
        http:winston.transports.Http,
        rotateFile:RotateFile
    };
    return _.mapValues(loggerConfig, function (config) {
        config = _.cloneDeep(config);
        config.transports = _.map(config.transports, function (transport) {
            var options = transport.options;
            return new transports[transport.type](options);
        });
        return new Logger(config);
    });
}
